
import Vue from 'vue';

import vuex from 'vuex';
Vue.use(vuex);

import axios from 'axios'

var store = new vuex.Store({
    state: {
        islogin: false,
        userinfo:''
    },
    // 同步数据修改
    mutations: {
        setUserinfo: function (state, value) {
            state.userinfo = value;
        },
        setLogin: function (state, value) {
            state.islogin = value;
        },

    },
    // 异步数据修改 网络请求
    actions: {
        // 注册请求
        reGist: function (state, value) {
            axios.post("users/regist", value)
                .then(res => {
                    state.commit(res.data);

                    // location.hash="/login"
                })
        },
    }

});

export default store;